using System;
using System.Text;
using System.ServiceModel;
using System.Collections.Generic;
using Services.WCF.Hosting;

namespace Services.WCF.Hosting
{
    [Serializable]
    [ServiceBehavior(
    AutomaticSessionShutdown = true,
    ConcurrencyMode = ConcurrencyMode.Single,
    InstanceContextMode = InstanceContextMode.Single,
    IncludeExceptionDetailInFaults = false,
    UseSynchronizationContext = true,
    ValidateMustUnderstand = true)]
    public class HostController : MarshalByRefObject, IHostController
    {
        public StopHosting OnStop;
        public ResumeHosting OnStart;
        public RecycleHosting OnRecycle;
        public EnumServices OnEnumServices;

        public HostController()
        {
            
        }

        public virtual void Start(String Name)
        {
            if (OnStart != null)
            {
                OnStart(Name);
            }
            else
            {
                throw new NotImplementedException();
            }
        
        }

        public virtual void Stop(String Name)
        {
            if (OnStop != null)
            {
                OnStop(Name);
            }
            else
            {
                throw new NotImplementedException();
            }
        
        }

        public virtual void ReStart(String Name)
        {
            if (OnRecycle != null)
            {
                OnRecycle(Name);
            }
            else
            {
                throw new NotImplementedException();
            }

        }

        public virtual HostControllerEntry[] EnumerateServices()
        {
            if (OnEnumServices != null)
            {
                return OnEnumServices();
            }
            else
            {
                throw new NotImplementedException();
            }
        }
   
    }

    
}
